<?php /*
	
*/ ?>
<?php include("system/config.inc.php");
$donotinclude = 1;
if(!isset($_SESSION['adminuserid']))
{
	header("location:index.php?msg=logfirst");
	die();
}

if(isset($_REQUEST['a']) && trim($_REQUEST['a']) == "3")
{
	if(isset($_REQUEST['intid']) && ($_REQUEST['intid'])!="")
	{
		$intid=mysql_real_escape_string($_REQUEST['intid']);
		$del=mysql_query("delete from tblorders where intid='$intid'");
		header("location:ordertotal.php");
		die();
	}	
}
?>
<?php include("inc/header.php");?>
<body>
<table width="80%" border="0" align="center" cellpadding="0" cellspacing="1" class="middlebackground">
  <tr>
    <td valign="top" align="center"><?php include(INC."top.inc.php");?></td>
  </tr>
  <tr valign="top">
    <td align="center">
	<form method="post" action="" name="ordertotal">
	<table width="91%" border="0" cellpadding="2" cellspacing="2" class="border">
      <tr>
        <td colspan="5" align="right" class="font"><strong>Search By Order Id:</strong> </td>
        <td colspan="2">
            <?php
			if(isset($_REQUEST['search']) && ($_REQUEST['search'])!="")
			{
			$searh=mysql_real_escape_string($_REQUEST['search']);
			?>
			<input name="search" type="text"  value="<?php echo stripslashes($searh);?>" size="15" />
			<?php } else { ?>
			<input name="search" type="text" value="" size="15" />
			<?php }?>
            
        </td>
        <td>
            <input name="Submit" type="submit" class="btn" value="Go" />
            
        </td>
      </tr>
      <tr class="bg1">
        <td colspan="10"><strong>Customer Orders- Total...</strong></td>
        </tr>
      <tr align="center" class="tblbg3">
        <td width="20">No.</td>
        <td width="61">Customers</td>
        <td width="59">
		<?php 
		if(isset($_REQUEST['sort']) && ($_REQUEST['sort'])=='alphaasc')
			{
		?>
		<a  class="ab1" href="ordertotal.php?sort=alphadesc">Total Purhased&nbsp;<img src="../images/down.gif" border="0" /></a>
		<?php 
			}
			else if(isset($_REQUEST['sort']) && ($_REQUEST['sort'])=='alphadesc')
			{
		?><a class="ab1" href="ordertotal.php?sort=alphaasc">Total Purhased&nbsp;<img src="../images/up.gif" border="0" /></a>
		<?php }
			else
			{
			 ?>
			 <a class="ab1" href="ordertotal.php?sort=alphadesc">Total Purhased</a>
			 <?php
		 }?> </td>
		<td width="38">Delete</td>
		<td width="91">Order Queue Status</td>
		<td width="45">Invoice</td>
		<td width="61">Packing slip</td>
		<td>Email</td>
      </tr>
	   <?php
		/**************************************
				PAGING CODE START
		**************************************/
			//$rowperpage=23;
			$tablename="tblorders";
			$per_page_keywords= "intcustomerid != 0";
			$per_page_sorts= " intcurrentorderstatus!=0";
			$wvar = "";
			include("system/paging.inc.php");

		/**************************************
				PAGING CODE ENDING
		**************************************/
	if(isset($_REQUEST['sort']) && ($_REQUEST['sort'])=='alphaasc')
	{
	$sql_select = "select * 
	from  ".$tablename."
	where ".$per_page_keywords."
	order by `deccurrencyvalue` asc
	Limit ".($page_no*$row_per_page).",".$row_per_page;
	}
	else if(isset($_REQUEST['sort']) && ($_REQUEST['sort'])=='alphadesc')
	{
	$sql_select = "select * 
	from  ".$tablename."
	where ".$per_page_keywords."
	order by `deccurrencyvalue` desc
	Limit ".($page_no*$row_per_page).",".$row_per_page;
	}
	else if(isset($_REQUEST['search']) && ($_REQUEST['search'])!="")
	{
	$searh=mysql_real_escape_string($_REQUEST['search']);
	$sql_select = "select * 
	from  ".$tablename."
	where intcustomerid != 0 and `intid` ='".mysql_real_escape_string($_REQUEST['search'])."'
	Limit ".($page_no*$row_per_page).",".$row_per_page;
	}
	else
	{
	$sql_select = "select * 
	from  ".$tablename."
	where ".$per_page_keywords."
	Limit ".($page_no*$row_per_page).",".$row_per_page;
	}
	$sql = $obj_db->select($sql_select);
	if($sql)
	{
	$i=0;
	for($j=0;$j<count($sql);$j++)
	 { 
		$screen_id=stripslashes($sql[$j]['intid']);
		 $i=$i+1;
		  ?>
      <tr align="center" class="<?php echo ($i%2==0)?"Hrnormal":"Hralter"; ?>" onMouseOver="this.className='Hrhover';" onMouseOut="this.className='<?php echo ($i%2==0)?"Hrnormal":"Hralter"; ?>';">
        <td><?php echo srchwordchangestyl($screen_id); ?></td>
        <?php 
		
		$sql_select1 = "SELECT * FROM `tblcustomers` WHERE `intcusid`=".stripslashes($sql[$j]['intcustomerid']);
		$sql1 = $obj_db->select($sql_select1);
		if($sql1)
		{			
			for($j1=0;$j1<count($sql1);$j1++)
			{
			?>
				<a href="customerdetails.php?detail=memberdetail&memberID=<?php echo stripslashes($sql[$j]['intcustomerid']);?>" class="aa"><td><?php echo stripslashes($sql1[$j1]['varcustfname'])."&nbsp;".stripslashes($sql1[$j1]['varcustlname']);?></td></a>
			
        <td>&pound;
          <?php 
		$sqlorpr="select * from tblorderproducts where intorderid='$screen_id'";
		$resor=$obj_db->select($sqlorpr);
		if($resor)
		{
			for($ct=0;$ct<count($resor);$ct++) {
			 $total = $total + $resor[$ct]['decfinalprice'];
			}
		echo $total; 
		}
		?></td>
		
		<td><a Title="Click here to Delete" class="link" href="ordertotal.php?a=3&intid=<?php echo $screen_id;?>" onClick="return confirm('Are you sure to delete this record ?');"  class="aa"><img src="images/delete.bmp" alt="Delete" border="0"></a></td>
	    <td><a Title='Click here for Change order queue' href="orderinfo.php?oid=<?php echo stripslashes($sql[$j]['intid']);?>" class="aa">Change Order Queue</a></td>
		<td><a href="#" Title='Click here for Invoice Details' onClick="window.open('invoice.php?order=<?php echo $screen_id;?>','','');" class="aa">Invoice</a></td>
		<td><a href="#" Title='Click here for Packing Slip Details' onClick="window.open('packingslip.php?order=<?php echo $screen_id;?>','','');" class="aa">Packing Slip</a></td>
		<td width="90"><a Title='Click here to E-Mail Customer' href="mailorder.php?cust=<?php echo stripslashes($sql[$j]['intcustomerid']);?>" style="cursor:hand;" class="aa"><?php echo stripslashes($sql1[$j1]['varcustemail']);?></a></td>
      </tr><?php
			 }
		}
 } } ?>
      <tr>
        <td colspan="10">&nbsp;</td>
        </tr>
      <tr>
        <td colspan="10" align="center"><?php pagindet_atbotttom_page($div_page_no,$page_no,$req_querystr,$total_db_rec,$row_per_page); ?></td>
        </tr>
    </table>
	</form>
	</td>
  </tr>
  <tr>
    <td align="center"><?php include(INC."bottom.php");?></td>
  </tr>
</table>

</body>
</html>
